/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "optionprovider")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Optionprovider.findAll", query = "SELECT o FROM Optionprovider o"),
    @NamedQuery(name = "Optionprovider.findByMenuProviderId", query = "SELECT o FROM Optionprovider o WHERE o.optionproviderPK.menuProviderId = :menuProviderId"),
    @NamedQuery(name = "Optionprovider.findBySubmenuProviderId", query = "SELECT o FROM Optionprovider o WHERE o.optionproviderPK.submenuProviderId = :submenuProviderId"),
    @NamedQuery(name = "Optionprovider.findByOptionProviderId", query = "SELECT o FROM Optionprovider o WHERE o.optionproviderPK.optionProviderId = :optionProviderId"),
    @NamedQuery(name = "Optionprovider.findByName", query = "SELECT o FROM Optionprovider o WHERE o.name = :name"),
    @NamedQuery(name = "Optionprovider.findByUrl", query = "SELECT o FROM Optionprovider o WHERE o.url = :url"),
    @NamedQuery(name = "Optionprovider.findByOrder", query = "SELECT o FROM Optionprovider o WHERE o.order = :order")})
public class Optionprovider implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OptionproviderPK optionproviderPK;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "url")
    private String url;
    @Basic(optional = false)
    @Column(name = "order")
    private short order;
    @JoinColumns({
        @JoinColumn(name = "menuProviderId", referencedColumnName = "menuProviderId", insertable = false, updatable = false),
        @JoinColumn(name = "submenuProviderId", referencedColumnName = "submenuProviderId", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Submenuprovider submenuprovider;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "optionprovider")
    private Collection<Defaultaccessprovider> defaultaccessproviderCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "optionprovider")
    private Collection<Accessprovider> accessproviderCollection;

    public Optionprovider() {
    }

    public Optionprovider(OptionproviderPK optionproviderPK) {
        this.optionproviderPK = optionproviderPK;
    }

    public Optionprovider(OptionproviderPK optionproviderPK, String name, short order) {
        this.optionproviderPK = optionproviderPK;
        this.name = name;
        this.order = order;
    }

    public Optionprovider(short menuProviderId, short submenuProviderId, short optionProviderId) {
        this.optionproviderPK = new OptionproviderPK(menuProviderId, submenuProviderId, optionProviderId);
    }

    public OptionproviderPK getOptionproviderPK() {
        return optionproviderPK;
    }

    public void setOptionproviderPK(OptionproviderPK optionproviderPK) {
        this.optionproviderPK = optionproviderPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public short getOrder() {
        return order;
    }

    public void setOrder(short order) {
        this.order = order;
    }

    public Submenuprovider getSubmenuprovider() {
        return submenuprovider;
    }

    public void setSubmenuprovider(Submenuprovider submenuprovider) {
        this.submenuprovider = submenuprovider;
    }

    @XmlTransient
    public Collection<Defaultaccessprovider> getDefaultaccessproviderCollection() {
        return defaultaccessproviderCollection;
    }

    public void setDefaultaccessproviderCollection(Collection<Defaultaccessprovider> defaultaccessproviderCollection) {
        this.defaultaccessproviderCollection = defaultaccessproviderCollection;
    }

    @XmlTransient
    public Collection<Accessprovider> getAccessproviderCollection() {
        return accessproviderCollection;
    }

    public void setAccessproviderCollection(Collection<Accessprovider> accessproviderCollection) {
        this.accessproviderCollection = accessproviderCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (optionproviderPK != null ? optionproviderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Optionprovider)) {
            return false;
        }
        Optionprovider other = (Optionprovider) object;
        if ((this.optionproviderPK == null && other.optionproviderPK != null) || (this.optionproviderPK != null && !this.optionproviderPK.equals(other.optionproviderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Optionprovider[ optionproviderPK=" + optionproviderPK + " ]";
    }
    
}
